<?php
/**
 * RedCross Application
 *
 * @copyright Copyright (c) 2010, Kristian Stokke Tryggestad, Rune Vikestad, Andreas Flaten Wist, Simen Nicolai Echholt, Ole Henrik Jahren
 */


class Core_Model_PasswordReset extends RedCross_Gateway_Base_PasswordReset
{

    public function createResetKey()
    {
        $key = '';
    	for ($i = 0; $i < 50; $i++) {
            $key .= chr(rand(33, 126));
    	}
    	return sha1($key);
    }

    public function createExpirationTime()
    {
        $expiration = new Zend_Date();
        $expiration->addMinute(30);
        return $expiration->get('YYYY-MM-dd HH:mm:ss');
    }

    public function getExpiration()
    {
        return new Zend_Date($this->expiration, Zend_Date::ISO_8601);
    }

    public function isExpired()
    {
        $now = new Zend_Date();
        if ($now->isEarlier($this->getExpiration())) {
        	return false;
        }
    	return true;
    }
}